<%@ page language="java" import="java.util.*,com.shop.pojo.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
	String path = request.getContextPath();
		String basePath = request.getScheme() + "://"
				+ request.getServerName() + ":"
				+ request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'shopcar.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="syscss/sys1.css">
	

</head>
<%
  			Set<Orderlist> car=(Set<Orderlist>)session.getAttribute("car"); 
  			
  			if(car==null||car.size()<1){
  			
  			
  			%>
  			<script type="text/javascript">
  			
  			window.alert("您还没购买任何东西哦快去购物吧！");
  		
  			window.location.href="<%=basePath%>main.jsp";
  			</script>
  			
  			
  				<% 
  			return;	}%>
<body>

	<table align="center">
		<tr>
			<th>书名：</th>
			<th>作者：</th>
			<th>数量</th>
			<th>单价：</th>
			<th>总价：</th>
			<th>操作：</th>
		</tr>
		<c:forEach items="${sessionScope.car }" var="ol">
			<tr>
				<td>${ol.book.bookname }</td>
				<td>${ol.book.bookauthor }</td>
				<td>${ol.olcount}</td>	
				<td>${ol.saleprice}</td>
				<td>${ol.saleprice*ol.olcount }</td>
			
				<td><a href="book/bookAction_change?idBook=${ol.book.idBook }&num=1">加一个</a>&nbsp;<a href="book/bookAction_change?idBook=${ol.book.idBook }&num=-1">减一个</a>&nbsp;<a href="book/bookAction_change?idBook=${ol.book.idBook }&num=-${ol.olcount}">不要了</a></td>
			</tr>
			<c:set var="sum" value="${ol.saleprice*ol.olcount+sum }"
				scope="page">
				
				</c:set>
		</c:forEach>


	</table>
	<hr style="width: 80%">
	<span style="text-align:right;margin-left:60%;color:red" >订单总价：${sum }</span>
	<form action="order/mkorder.jsp" method="post">
<input type="hidden" value="${ pageScope.sum}"  name="sum">
<input type="submit" value="提交订单"/>
</form>
</body>
</html>
